<h1>ShapeStyle</h1>

<p>ShapeStyle is used to change the drawing environment when a shape is drawn. 
Three operations can be performed:</p>

<div style="padding-left:20px; margin-bottom:10px;">
<ul>
<li>Select a line style or fill style.</li>
<li>Move the current drawing point.</li>
<li>Define a new set of line and fill styles.</li>
</ul>
</div>

<p>A ShapeStyle can specify one or more of the operations rather than 
pecifying them in separate ShapeStyles - compacting the size of the 
binary data when the object is encoded. Conversely if an operation is not 
defined then the values may be omitted.</p>

<table>

<tr>
<th nowrap>Field Name</th>
<th>Type</th>
<th>Size</th>
<th>Description</th>
</tr>

<tr>
<td nowrap valign="top">type</td>
<td nowrap valign="top"></td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>Identifies the data structure when it is encoded.</td>
</tr>

<tr>
<td nowrap valign="top">hasStyles</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Are new line or fill styles defined.</td>
</tr>

<tr>
<td nowrap valign="top">hasLineStyle</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Is a new line style specified.</td>
</tr>

<tr>
<td nowrap valign="top">hasAltFillStyle</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Is a new fill style specified for overlapping areas.</td>
</tr>

<tr>
<td nowrap valign="top">hasFillStyle</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Is a new fill style specified.</td>
</tr>

<tr>
<td nowrap valign="top">hasMove</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Are the coordinates of the drawing point changed.</td>
</tr>

<tr>
<td nowrap valign="top">size</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">5</td>
<td>The number of bits used to encode the drawing point coordinates.</td>
</tr>

<tr>
<td nowrap valign="top">x</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">&lt;size&gt;</td>
<td>Optional. The absolute x-coordinate of the new drawing point.</td>
</tr>

<tr>
<td nowrap valign="top">y</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">&lt;size&gt;</td>
<td>Optional. The absolute y-coordinate of the new drawing point.</td>
</tr>

<tr>
<td nowrap valign="top">fillStyle</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">&lt;n&gt;</td>
<td>Optional. The ordinal index (starting at 1) of the new fill style to be 
selected from the array of fill styles defined for the shape.</td>
</tr>

<tr>
<td nowrap valign="top">altFillStyle</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">&lt;n&gt;</td>
<td>Optional. The ordinal index (starting at 1) of the new fill style for 
overlapping areas selected from the array of fill styles defined for 
the shape.</td>
</tr>

<tr>
<td nowrap valign="top">lineStyle</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">&lt;n&gt;</td>
<td>Optional. The ordinal index (starting at 1) of the new line style to be 
selected from the array of line styles defined for the shape.</td>
</tr>

<tr>
<td nowrap valign="top">fillStyleCount</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>The number of fill styles following. For shapes that contain more than 
254 fill styles this field is set to 0xFF (255) and the following 16-bit field
is used to specify the number of fill styles.</td>
</tr>

<tr>
<td nowrap valign="top">fillStyleCountExtended</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>Optional. Allows shapes to be define with more than 254 fill styles. This 
field is rarely used in practice.</td>
</tr>

<tr>
<td nowrap valign="top">fillStyles</td>
<td nowrap valign="top">FillStyle[n]</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>An array of fill styles used to fill the area enclosed by the shape.</td>
</tr>

<tr>
<td nowrap valign="top">lineStyleCount</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>The number of line styles following. For shapes that contain more than 
254 line styles this field is set to 0xFF (255) and the following 16-bit field
is used to specify the number of line styles.</td>
</tr>

<tr>
<td nowrap valign="top">lineStyleCountExtended</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>Optional. Allows shapes to be define with more than 254 line styles. This 
field is rarely, if ever, used in practice.</td>
</tr>

<tr>
<td nowrap valign="top">lineStyles</td>
<td nowrap valign="top">LineStyle[n]</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>An array of line styles used to fill the area enclosed by the shape.</td>
</tr>

</table>

<p>Line and Fill styles are selected by the index position, starting at 1, of 
the style in an array of styles. An index of zero means that no style is selected. 
Using the constant Transform.VALUE_NOT_SET means that the current style is 
unchanged. Two types of fill style are supported: fillStyle is used where a shape 
does not contain overlapping areas and altFillStyle is used where areas overlap. 
This differs from graphics environments that only support one fill style as the 
overlapping area would form a hole in the shape and not be filled.</p>

<p>In the following example, when a shape is drawn the fillStyle defines the 
style to the left of the line drawing the outline while the altFillStyle defines 
the style applied to the right of the outline.</p>

<img src="fillStyles.gif">

<p>New fill and line styles can be added to the ShapeStyle to change 
the way shapes are drawn.</p>

<p>A new drawing point is specified using the absolute x and y coordinates. If 
a ShapeStyle is the first in a shape then the current drawing point 
is the origin of the shape (0,0).</p>

<h1 class="datasheet">Optional Attributes</h1>

<p>Since the ShapeStyle can encode three different types of operation, 
the unused attributes are optional. Setting line or fill styles to the framework 
constant Transform.VALUE_NOT_SET omits the attribute when the object is 
encoded - reduced the size.</p>

<p>For the line and fill styles setting the respective attribute to T
ransform.VALUE_NOT_SET is different from setting to zero. When the attribute is 
set to Transform.VALUE_NOT_SET attribute is not encoded. When the attribute is 
set to zero then that instructs the Flash Player that no current line or fill 
style is selected. The latter is important when filling areas of a shape that 
overlap - the altFillStyle attribute will be set to the desired style while the 
lineStyle and fillStyle attributes are set to zero.</p>

<p>Similarly moveX and moveY may be set to Transform.VALUE_NOT_SET to indicate 
that the current drawing point will not be changed.  This can also be achieved 
by setting moveX and moveY to zero. However using Transform.VALUE_NOT_SET means 
that the attributes are not encoded reducing the binary representation. For 
large files the savings can be significant.</p>

<p>The line or fill style arrays May be empty if no new styles are being specified.</p>

<p>Note that the values for the moveX and moveY attributes and the line and fill 
styles arrays are defined in pairs and are optional only if both are set to zero 
or NULL respectively.</p>

<h2>History</h2>

<p>ShapeStyle represents the StyleChange record from the Macromedia 
Flash (SWF) File Format Specification. It was introduced in Flash 1.</p>
